import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
// import {
// 	uglify
// } from "rollup-plugin-uglify";
import { terser } from "rollup-plugin-terser";
import typescript from "rollup-plugin-typescript2";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";

export default {
  input: "src/Index.ts",
  output: [
    {
      file: "dist/R2.js",
      format: "umd",
      name: "R2",
      sourcemap: false,
      freeze: false,
    },
  ],
  watch: {
    exclude: "node_modules/**",
  },
  plugins: [
    typescript({ useTsconfigDeclarationDir: true, abortOnError: false }),
    resolve(),
    commonjs(),
    babel({
      exclude: "node_modules/**", // 防止打包node_modules下的文件
      runtimeHelpers: true, // 使plugin-transform-runtime生效
    }),
    // uglify(),
    terser(),
    serve({
      open: false,
      contentBase: "dist",
    }),
    livereload(),
  ],
  external: ["canvas"],
};
